﻿@model IList<OrderModel.AddOrderProductModel.ProductVariantAttributeModel>
@using Nop.Web.Framework;
@using Nop.Core.Domain.Catalog;
@if (Model.Count > 0)
{
    <div class="product-attributes-input">
        <dl>
            @foreach (var attribute in Model)
            {
                string controlId = string.Format("product_attribute_{0}_{1}", attribute.ProductAttributeId, attribute.Id);
                string textPrompt = !string.IsNullOrEmpty(attribute.TextPrompt) ? attribute.TextPrompt : attribute.Name;
                <dt><span class="text-prompt">
                    @textPrompt
                </span>
                    @if (attribute.IsRequired)
                    {
                        <span class="required">*</span>
                    }
                </dt>
                <dd>
                    @switch (attribute.AttributeControlType)
                    {
                        case AttributeControlType.DropdownList:
                            {
                        <select name="@(controlId)" id="@(controlId)">
                            @if (!attribute.IsRequired)
                            {
                                <option value="0">---</option>
                            }
                            @foreach (var pvaValue in attribute.Values)
                            {
                                <option selected="@pvaValue.IsPreSelected" value="@pvaValue.Id">@pvaValue.Name
                                </option>
                            }
                        </select>
                            }
                            break;
                        case AttributeControlType.RadioList:
                        case AttributeControlType.ColorSquares:
                            {
                        <ul class="option-list">
                            @foreach (var pvaValue in attribute.Values)
                            {
                                <li>
                                    <input id="@(controlId)" type="radio" name="@(controlId)" value="@pvaValue.Id" checked="@pvaValue.IsPreSelected" />
                                    <label for="@(controlId)">@pvaValue.Name</label>
                                </li>
                            }
                        </ul>
                            }
                            break;
                        case AttributeControlType.Checkboxes:
                            {
                        <ul class="option-list">
                            @foreach (var pvaValue in attribute.Values)
                            {
                                <li>
                                    <input id="@(controlId)" type="checkbox" name="@(controlId)" value="@pvaValue.Id" checked="@pvaValue.IsPreSelected" />
                                    <label for="@(controlId)">@pvaValue.Name</label>
                                </li>
                            }
                        </ul>
                            }
                            break;
                        case AttributeControlType.TextBox:
                            {
                        <input name="@(controlId)" type="text" id="@(controlId)" class="textbox" />
                            }
                            break;
                        case AttributeControlType.MultilineTextbox:
                            {
                        <textarea cols="20" id="@(controlId)" name="@(controlId)" rows="2"></textarea>
                            }
                            break;
                        case AttributeControlType.Datepicker:
                            {
                        @Html.DatePickerDropDowns(controlId + "_day", controlId + "_month", controlId + "_year", DateTime.Now.Year, DateTime.Now.Year + 1)
                            }
                            break;
                        case AttributeControlType.FileUpload:
                            {
                        <input type="file" id="@(controlId)" name="@(controlId)"></input>
                            }
                            break;
                    }
                </dd>
            }
        </dl>
    </div>
}